package com.persondemo.videoappliction.ui.vip.presenter;

import com.persondemo.videoappliction.bean.ShengtieBean;
import com.persondemo.videoappliction.net.BaseApi;
import com.persondemo.videoappliction.net.BaseObserver;
import com.persondemo.videoappliction.net.RxSchedulers;
import com.persondemo.videoappliction.ui.base.BasePresenter;
import com.persondemo.videoappliction.ui.vip.contract.ShengTieContract;

import javax.inject.Inject;

/**
 * Created by Administrator on 2018/4/27.
 */

public class ShengTiePresenter extends BasePresenter<ShengTieContract.View> implements ShengTieContract.Presenter {
    private BaseApi baseApi;

    @Inject
    public ShengTiePresenter(BaseApi baseApi) {
        this.baseApi = baseApi;
    }

    @Override
    public void getdata(String device, String page) {
        baseApi.getshengtie(device, page)
                .compose(RxSchedulers.applySchedulers())
                .compose(mView.bindToLife())
                .subscribe(new BaseObserver<ShengtieBean>() {
                    @Override
                    public void onSuccess(ShengtieBean shengtieBean) {
                        if (!page.equals("1")) {
                            mView.loadmore(shengtieBean);
                        } else {
                            mView.loaddata(shengtieBean);
                        }
                    }

                    @Override
                    public void onFail(Throwable e) {
                        mView.showFaild();
                    }
                });
    }
}
